package com.pet.pet.app.parent;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.pet.pet.entity.UPetEntity;
import com.pet.pet.entity.UPetLogEntity;
import com.pet.pet.service.UPetLogService;
import com.pet.pet.service.UPetService;
import com.pet.pet.service.UPetUrlService;
import com.pet.pet.app.redis.RedisUtils;
import com.pet.pet.app.requst.Request;
import com.pet.pet.utlis.ValPuls;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Date;
import java.util.List;

public class AncestorsProcessor {
    public static final String DATA_KEY = "data";
    /**
     * 可用
     */
    protected static final Integer USER_STATE_YES = 1;
    /**
     * 不可用
     */
    protected static final Integer USER_STATE_NO = 2;
    @Autowired
    protected ValPuls val;
    @Autowired
    protected UPetLogService uPetLogService;
    @Autowired
    protected UPetUrlService uPetUrlService;
    @Autowired
    protected UPetService uPetService;
    @Autowired
    protected Request request;
    @Autowired
    protected RedisUtils redisUtils;
    protected static final Integer CATCH_CODE = 300;
    /**
     * 可用与不可用
     */
    protected static final Integer YES = 1;
    protected static final Integer NO = 0;


    protected void saveLog(Integer code,String msg,Long uId,Integer impact){
        UPetLogEntity uPetLogEntity = new UPetLogEntity();
        uPetLogEntity.setCreateTime(new Date());
        uPetLogEntity.setErrorCode(code);
        uPetLogEntity.setErrorInfo(msg);
        uPetLogEntity.setUId(uId);
        uPetLogEntity.setImpact(impact);
        uPetLogService.save(uPetLogEntity);
    }

    protected void modify(Long uId, Integer state) {
        UpdateWrapper<UPetEntity> uPetEntityUpdateWrapper = new UpdateWrapper<>();
        uPetEntityUpdateWrapper.eq("u_id", uId);
        uPetEntityUpdateWrapper.set("state", state);
        uPetEntityUpdateWrapper.set("updateTime", new Date());
        uPetService.update(uPetEntityUpdateWrapper);
    }


}
